import axios from '@/utils/axios'

const loginApi = '/uaa/manage/login/account_login' // 登录
const findSerialApi = '/uaa/manage/login/find_serial' // 登录
const loginQrcodeApi = '/uaa/manage/login/login_qrcode' // 登录二维码
const loginQrcodeStateApi = '/uaa/manage/login/login_qrcode_status' // 登录二维码状态
const userInfoApi = '/sp_admin/personal/user_info_menus' // 用户信息
const modifyPwApi = '/sp_admin/personal/modify_pw' // 密码
const bindWxApi = '/sp_admin/user/wx/bind' // 绑定微信
const bindWxStateApi = '/sp_admin/user/wx/query_bind_state' // 解绑微信状态
const unBindWxApi = '/sp_admin/user/wx/unbind_wx' // 解绑微信

/**
 * @desc 登录
 */
export const login = ({ data }) => {
  return axios.post(loginApi, data)
}

/**
 * @desc 找回编号
 */
export const findSerial = ({ data }) => {
  data.scope = 1
  return axios.post(findSerialApi, data)
}

/**
 * @desc 登录二维码
 */
export const loginQrcode = ({ data }) => {
  return axios.post(loginQrcodeApi, data)
}

/**
 * @desc 查询登录二维码状态
 */
export const loginQrcodeState = ({ params }) => {
  return axios({
    url: loginQrcodeStateApi,
    method: 'get',
    params: params
  })
}

/**
 * @desc 用户信息
 */
export const getUserInfo = () => {
  return axios.get(userInfoApi)
}

/**
 * @desc 密码
 */
export const modifyPw = ({ data }) => {
  return axios.post(modifyPwApi, data)
}

/**
 * @desc 绑定微信
 */
export const bindWx = ({ data }) => {
  return axios.post(bindWxApi, data)
}

/**
 * @desc 绑定状态
 */
export const bindWxState = ({ params }) => {
  return axios({
    url: bindWxStateApi,
    method: 'get',
    params: params
  })
}

/**
 * @desc 解绑微信
 */
export const unBindWx = ({ data }) => {
  return axios.post(unBindWxApi, data)
}

// 渠道补充信息详情
export function detail(params) {
  return axios({
    url: '/sp_admin/channel/detail',
    method: 'get',
    params: params
  })
}
